package com.ruoyi.system.mc.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.utils.SecurityUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Objects;

/*
 *  @author 雨安
 *  类名： McRoomPerson
 *  创建时间：2024/5/31
 */
@Data//getter + setter + toString
@AllArgsConstructor//有参构造方法
@NoArgsConstructor//无参构造方法
@TableName("mc_room_person")//表名 聊天对应表
public class McRoomPerson extends BaseEntity{

    @TableId(type = IdType.AUTO)
    private Long rpId;

    private Long roomId;

    private Long userId;

    @TableField(exist = false)
    private String userName;

    @TableField(exist = false)
    private String adminImg;

    //获取条件构造器
    public LambdaQueryWrapper<McRoomPerson> getLambdaQueryWrapper(McRoomPerson mcRoomPerson){
        //返回条件构造器
        return new LambdaQueryWrapper<McRoomPerson>()
                //通过登录的人查询对应展示聊天室
                .eq(McRoomPerson::getUserId, SecurityUtils.getUserId())
                //通过聊天室ID查找聊天
                .eq(Objects.nonNull(mcRoomPerson.getRoomId()),McRoomPerson::getRoomId,mcRoomPerson.getRoomId())
                //查询未逻辑删除的数据
                .eq(McRoomPerson::getDeleteFlag,Boolean.FALSE);
    }

}
